package com.vinjune.algorithm.recursion;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
*@author 作者：zhangwenjun
*@version 创建时间：2016年1月27日 上午9:33:28
*类说明
*/

public class Hanoi {
	
	public static void main(String[] args) throws NumberFormatException, IOException {
		
		int n;
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		System.out.println("请输入盘数：");
        
		n=Integer.parseInt(buf.readLine());
		
		Hanoi h = new Hanoi();
		
		h.move(n, 'A', 'B', 'C');
	}
	
	
	public void move(int n, char a, char b, char c){
		
		if(1==n)
			System.out.println("盘 " + n + " 由 " + a + " 移至 " + c);
		else{
			move(n-1, a, c, b);
			System.out.println("盘 " + n + " 由 " + a + " 移至 " + c);
			move(n-1, b, a, c);
		}
	}
	

}


